home *** CD-ROM | disk | FTP | other *** search
/ Aminet 19 / Aminet 19 (1997)(GTI - Schatztruhe)[!][Jun 1997].iso / Aminet / demo / mag / trash3_2.lha / fuentes / STARTUP-FUENTES.lha / Startup2.s < prev   
Text File  |  1996-12-07  |  11KB  |  404 lines

  1. ;-----------------------------------------
  2. ;                                        
  3. ; Generic Demo Startup Code version 1.06
  4. ; Coded by Flynn/Capsule in 1996.        
  5. ;                                        
  6. ; * Works on ALL Amigas.                 
  7. ; * Generic version (68020 + FAST)      
  8. ; * Aimed at AGA/'020+ demos.            
  9. ; * Full 68000 - 68060 support.
  10. ;                                        
  11. ;-----------------------------------------
  12.  
  13.         INCLUDE Include:macros/macros.i ; cambialo a donde 
  14.                         ; pongas el macros.i
  15.  
  16.     IFD _PHXASS_        ; Comenta estas lineas
  17.     MACHINE 68030        ; si no usas PHX
  18.     ENDIF            ;
  19.  
  20.     section    startup,code
  21.     
  22. Start
  23.  
  24. ;-----------------
  25. ; Processor check.
  26. ;-----------------
  27.  
  28.         move.l  4.w,a6          ; exec base.
  29.         move.w  $128(a6),d0     ; AttnFlags
  30.  
  31.         lea     _cpu,a1
  32.         lea     _status,a2
  33.         
  34.         btst    #0,d0
  35.         bne.s   _010            ; 68010
  36.         move.b  #"0",(a1)
  37.         move.w  #"ER",(a2)
  38.         bra.b   _done
  39.  
  40. _010    btst    #1,d0
  41.         bne.s   _020            ; 68020
  42.         move.b  #"1",(a1)
  43.         move.w  #"ER",(a2)
  44.         bra.b   _done
  45.  
  46. _020    btst    #2,d0
  47.         bne.s   _030            ; 68030
  48.         move.b  #"2",(a1)
  49.         bra.b   _done
  50. _030    btst    #3,d0
  51.         bne.s   _040            ; 68040
  52.         move.b  #"3",(a1)
  53.         bra.b   _done
  54. _040    btst    #7,d0
  55.         bne.s   _060            ; 68060
  56.         move.b  #"4",(a1)
  57.         bra.b   _done
  58. _060    move.b  #"6",(a1)
  59.  
  60. _done   bsr AbrirDOS            ; open DOS.library
  61.         WRITE _header,_stdout   ; write header
  62.  
  63.         bsr     AGA_Check       ; Check for AGA chip set
  64.  
  65.         cmp.l   #"AGA.",d7
  66.         bne     _error1
  67.  
  68.         WRITE _aga,_stdout      
  69.  
  70.         bra     _continue
  71.  
  72. _error1 lea     _status,a2
  73.         move.w  #"ER",(a2)
  74.         WRITE   _not_aga,_stdout
  75.         bra     _failed
  76.  
  77. _continue
  78.  
  79.         move.l  4.w,a6
  80.         cmp.b   #50,530(A6)     ; Check for PAL/NTSC
  81.         bne     _nopal
  82.  
  83.         WRITE   _pal,_stdout
  84.  
  85.         bra     _cont2
  86.  
  87. _nopal  lea     _status,a2
  88.         move.w  #"ER",(a2)
  89.         WRITE   _ntsc,_stdout
  90.         bra     _failed
  91.  
  92. _cont2
  93.         lea     _status,a2
  94.         cmp.w   #"ER",(a2)
  95.         bne     _systemok
  96. _failed
  97.         WRITE   _abort1,_stdout
  98.  
  99.         bsr CerrarDOS              ; cerramos librería DOS
  100.         moveq #0,d0                ; retorno al Shell sin error
  101.         rts                        ; retorno
  102.  
  103. _systemok
  104.  
  105. ;Now we can check for chip/fast memory...
  106.  
  107.  
  108.         lea     _chipmem,a2
  109.  
  110.         move.l  4.w,a6          ; exec base
  111.         move.l  #$00020002,d1   ; chip mem
  112.         jsr     -216(a6)        ; _LVOAvailMem
  113.         move.l  d0,(a2)+
  114.         move.l  #$00020004,d1   ; fast mem
  115.         jsr     -216(a6)        ; _LVOAvailMem
  116.         move.l  d0,(a2)
  117.  
  118. ; And now let's convert the data into ASCII...
  119.  
  120.         lea     _chipmem,a2
  121.         lea     _cmem,a3        ; string pointer
  122.         lea     _values,a4      ; Table for Hex-Ascii conversion
  123.         move.l  (a2)+,d0        ; amount of chip mem
  124.  
  125.         bsr     converter       ; do conversion.
  126.  
  127.         move.l  (a2),d0         ; amount of fast mem
  128.         lea     _fmem,a3        ; string pointer
  129.  
  130.         bsr     converter       ; convert values
  131.  
  132.         WRITE   _chip,_stdout
  133.  
  134.         lea     _fastmem,a2
  135.         move.l  (a2),d0
  136.         cmp.l   #0,d0           ; No fast mem?
  137.         bne     _fast_ok
  138.  
  139.         WRITE   _abort2,_stdout
  140.         bsr     CerrarDOS
  141.         moveq   #0,d0
  142.         rts
  143.  
  144. _fast_ok
  145.         WRITE   _passd,_stdout
  146.  
  147.         bsr     CerrarDOS       ; close dos.library
  148.         
  149. ;--------------------------------------------------
  150. ; Close system and store old IRQ/DMA/Copper values.
  151. ;--------------------------------------------------
  152.  
  153.         lea     gfx_lib,a1      ; open graphics.library
  154.         moveq   #0,d0
  155.         move.l  4.w,a6          ; exec base
  156.         jsr     -552(a6)        ; _LVOOpenLibrary
  157.  
  158.         move.l  d0,_gfxbase     ; store open gfxlibrary pointer
  159.         move.l  d0,a6
  160.         move.l  38(a6),_oldcopper       ; store old copper list address
  161.         move.l  34(a6),_oldview         ; store old WB view.
  162.  
  163.         jsr     -228(a6)        ; _LVOWaitBlitt
  164.         jsr     -456(a6)        ; _LVOOwnBlitter                
  165.  
  166.         moveq   #0,d7
  167.         move.l  d7,a1
  168.  
  169.         jsr     -222(a6)        ; _LVOLoadView(Null)
  170.         jsr     -270(a6)        ; _LVOWaitTOF
  171.         jsr     -270(a6)        ; _LVOWaitTOF
  172.  
  173.         move.l  4.w,a6
  174.         jsr     -132(a6)        ; _LVOForbid
  175.  
  176.         lea     GetVBR(pc),a5
  177.         jsr     -$1e(a6)        ; _LVOSupervisor
  178.  
  179.         move    $DFF01C,_intenar
  180.         move    $DFF01E,_intreqr
  181.         move    $DFF002,_dmaconr
  182.         move    $DFF010,_adkconr
  183.  
  184.         move    #%0111111111111111,$DFF09A      ; Intena
  185.         move    #%1100000000100000,$DFF09A      ; enable needed IRQs
  186.  
  187.         move.l  _gfxbase,a6
  188.         jsr     -270(a6)        ; WaitTOF
  189.  
  190.         move    #%0111111111111111,$DFF096      ; DMACONW
  191.         move    #%1000001111000000,$DFF096
  192.         
  193.  
  194.         move.l  _vectorbase,a0
  195.         move.l  $6c(a0),_int3save               ; store original vblank int.
  196.                 
  197.         jsr     _maincode       ; call main demo code
  198.  
  199.  
  200.         move.l  _vectorbase,a0
  201.         move.l  _int3save,$6c(a0)       ; restore old level3 int.
  202.  
  203.         move    _intenar,d7
  204.         bset    #$f,d7
  205.         move    d7,$DFF09A              ; restore old interrupts.
  206.  
  207.         move    _intreqr,d7
  208.         bset    #$f,d7
  209.         move    d7,$DFF09C              ; the same...   
  210.         
  211.         move    _dmaconr,d7
  212.         bset    #$f,d7
  213.         move    d7,$DFF096              ; restore old DMAs
  214.  
  215.         move    _adkconr,d7
  216.         bset    #$f,d7
  217.         move    d7,$DFF09E              ; restore Adkcon
  218.  
  219.         move.l  _gfxbase,a6
  220.         move.l  _oldview,a1
  221.         jsr     -222(a6)                ; _LVOLoadview(OldView)
  222.  
  223.         move.l  _oldcopper,$dff080      ; restore old copper list.
  224.  
  225.         jsr     -462(a6)                ; _LVODisownBlitter
  226.  
  227.         move.l  4.w,a6
  228.         move.l  _gfxbase,a1
  229.         jsr     -414(a6)                ; close graphics.library
  230.  
  231.         jsr     -138(a6)                ; _LVOPermit
  232.  
  233.         moveq   #0,d0
  234.         rts
  235.         
  236. ;--------------------------------------------------------------------
  237. ; Hex to Ascii conversion routine.
  238. ; IN: D0.l = Number, A3 = Pointer to string, A4 = Pointer to _values.
  239. ;--------------------------------------------------------------------
  240.  
  241. converter
  242.         move.l  d0,d6   ; store number.
  243.         moveq   #28,d7  ; bits to be shifted.
  244. do_conv
  245.         lsr.l   d7,d0   ; d0.b is now MSB
  246.         and.w   #$000F,d0
  247.         move.b  (A4,d0.w),(a3)+ ; Copy value to string.
  248.  
  249.         move.l  d6,d0
  250.         subq.w   #4,d7
  251.         cmp.w     #-4,d7
  252.         bne     do_conv 
  253.  
  254.         rts
  255.  
  256. ;-------------------------
  257. ; AGA chipset tester.
  258. ; Setpatch MUST be loaded!
  259. ;-------------------------
  260.  
  261. AGA_Check
  262.         lea     gfx_lib,a1
  263.         moveq   #0,d0
  264.         move.l  4.w,a6
  265.         jsr     -552(a6)
  266.  
  267.         btst    #2,$EC(A0)
  268.         bne.s   is_aa
  269.         moveq   #0,d7
  270.         bra.s   not_aga
  271. is_aa   move.l  #'AGA.',d7      
  272.  
  273. not_aga move.l  a0,a1
  274.         jsr     -414(a6)
  275.         rts
  276.  
  277. ;--------------------------------------
  278. ; Store VBR value.
  279. ; Processor MUST be in Supervisor mode.
  280. ;--------------------------------------
  281.  
  282. GetVBR  movec   VBR,D0
  283.         lea     _vectorbase,a0
  284.         move.l  d0,(a0)
  285.         RTE
  286.  
  287. ;-------------------
  288. ; dos.library stuff.
  289. ;-------------------
  290.  
  291. AbrirDOS:
  292.          move.l   _AbsExecBase,_ExecBase   ; store exec base
  293.          lea      dos_name,a1              ; dos.library
  294.          moveq    #0,d0                    ; any version
  295.          CALLSYS  OpenLibrary,_ExecBase   
  296.          move.l   d0,_DOSBase              ; store Dos.library pointer
  297.          beq      ERROR                    
  298.  
  299.          CALLSYS  Output,_DOSBase          ; output descriptor.
  300.          move.l   d0,_stdout               ; store descriptor.
  301.          beq      CerrarDOS                
  302.          CALLSYS  Input,_DOSBase           ; input descriptor.
  303.          move.l   d0,_stdin                
  304.          beq      CerrarDOS                
  305.          rts                               
  306.  
  307. CerrarDOS:
  308.         move.l   _DOSBase,a1               ; 
  309.         CALLSYS  CloseLibrary,_ExecBase    ;close dos.library
  310.         rts                                
  311.  
  312. ERROR:  clr.l    d0        ; exit to shell in case of error.
  313.         rts
  314.  
  315. ;------------------------------------------------------------------------
  316. ; Text and misc data for startup/restore routines.
  317. ;------------------------------------------------------------------------
  318.  
  319.  
  320.     section    stup_data,data
  321.     
  322. _stdout         ds.l    1             
  323. _stdin          ds.l    1             
  324. _ExecBase       ds.l    1             
  325. _DOSBase        ds.l    1             
  326.  
  327. _status dc.w    0
  328.  
  329. _values dc.b    '0123456789ABCDEF'
  330.  
  331. _chipmem        dc.l    0
  332. _fastmem        dc.l    0
  333.  
  334. _gfxbase        dc.l    0
  335. _oldcopper      dc.l    0
  336. _oldview        dc.l    0
  337. _vectorbase     dc.l    0
  338. _intenar        dc.w    0
  339. _intreqr        dc.w    0
  340. _dmaconr        dc.w    0
  341. _adkconr        dc.w    0
  342. _int3save       dc.l    0
  343.  
  344. dos_name        dc.b    "dos.library",0
  345. gfx_lib     dc.b    "graphics.library",0,0
  346.  
  347. _header dc.b LF,' Hardware Configuration Test 1.06 © 1996 Capsule '
  348.         dc.b LF,' -----------------------------------------------',LF
  349.         dc.b LF,' 680'
  350. _cpu    dc.b 'x0 processor found...........[68020+ needed]'
  351.  
  352. _header_long EQU *-_header
  353.  
  354. _aga    dc.b LF,' AGA chipset found..................[AGA needed]'
  355.                
  356. _aga_long EQU *-_aga
  357.  
  358. _not_aga dc.b LF,' AGA chipset not found..............[AGA needed]'
  359.  
  360. _not_aga_long EQU *-_not_aga
  361.  
  362. _pal    dc.b  LF,' PAL display........................[PAL needed]'
  363.  
  364. _pal_long       equ     *-_pal
  365.  
  366. _ntsc   dc.b  LF,' System is not in PAL mode..........[PAL needed]'
  367.  
  368. _ntsc_long      EQU     *-_ntsc
  369.  
  370. _chip   dc.b  LF,LF,' Chip Memory: $'
  371.  
  372. _cmem   dc.b  '00000000 bytes available.'
  373.  
  374.         dc.b  LF,' Fast Memory: $'
  375.  
  376. _fmem   dc.b  '00000000 bytes available.'
  377.  
  378. _chip_long      equ     *-_chip
  379.  
  380. _abort1 dc.b  LF,LF,' Hardware test failed. Program aborted...',LF,LF
  381.  
  382. _abort1_long   EQU *-_abort1
  383.  
  384. _abort2 dc.b  LF,LF,' Sorry, this demo requires at least 2Mb of FAST Memory.'
  385.         dc.b  LF,LF
  386.  
  387. _abort2_long   EQU *-_abort2
  388.         
  389. _passd dc.b LF,LF,' Hardware test passed. Running demo...',LF,LF
  390.  
  391. _passd_long EQU 42
  392.  
  393.  
  394. ;----------------------------------------------------------------------------
  395. ; Real code starts here if everything went ok.
  396. ;----------------------------------------------------------------------------
  397.  
  398.  
  399.     section    democode,code
  400.     
  401.                 
  402. _maincode       nop
  403.                 rts
  404.